home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Mac OS / Apple Guide / Engineering / Context Check Modules / Desktop Printer CC / IsThereDTPrinter.c next >
Encoding:
C/C++ Source or Header  |  1994-05-02  |  1.6 KB  |  76 lines  |  [TEXT/KAHL]

  1. /****************************************/
  2.     
  3. /*    IsThereDTPrinter.c                    */
  4. /*    Author:             Shemin Gau, IP    */
  5. /*    Revision History:    02/03/94        */
  6.  
  7. /****************************************/
  8.  
  9.  
  10. #include <Memory.h>
  11. #include <Resources.h>
  12. #include <Types.h>
  13. #include <String.h>
  14. #include <OSUtils.h>
  15. #include <ToolUtils.h>
  16. #include <Errors.h>
  17.  
  18.  
  19. OSErr SetContextResult(void* theData, Size theSize, Ptr* outMessage, Size* outSize);
  20.  
  21.  
  22. pascal OSErr main(char msg, Size inSize, void* outMessage, Size* outSize, Handle ignoreMe)
  23. {        
  24.     Handle            my_hndl;    
  25.     short            old_file = CurResFile();
  26.     char            *str_holder = '\0';
  27.     OSErr            my_err = noErr;
  28.     
  29.     Boolean        result = false;
  30.     
  31.         
  32.     UseResFile(0);
  33.     
  34.     //It is not a right way to  pass the id directly. But it's a unique number, I did it anyway.
  35.     
  36.     if (my_hndl = (Handle)Get1Resource('STR ', -8192)) {
  37.         BlockMove(*my_hndl, str_holder, (long)(**my_hndl + 1));
  38.     } else {
  39.         my_err = ResError();
  40.     }
  41.     ReleaseResource((Handle)my_hndl);
  42.     
  43.     //This one is really tricky, the handle is actually a pointer to the 'STR ',
  44.     //plus a control character.
  45.     
  46.     UseResFile(old_file);
  47.     if ((*str_holder) && (my_err == noErr)) {
  48.         result = true;
  49.         my_err = SetContextResult(&result, sizeof(Boolean), outMessage, outSize);
  50.         return(my_err);
  51.     } else {
  52.         //return(1);        /* False */
  53.         my_err = SetContextResult(&result, sizeof(Boolean), outMessage, outSize);
  54.         return(my_err);
  55.     }
  56.         
  57. }
  58.  
  59.  
  60. OSErr SetContextResult(void* theData, Size theSize, Ptr* outMessage, Size* outSize)
  61. {
  62.     Ptr    p;
  63.     
  64.     if (p = NewPtr(theSize)) {
  65.         BlockMove(theData, p, theSize);
  66.         
  67.         *outSize = theSize;
  68.         *outMessage    = p;
  69.         
  70.         return(noErr);
  71.     } else {
  72.         return(MemError());
  73.     }
  74. }
  75.  
  76.